package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.uuid.UUID;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HotspotDataRealtime;
import com.ruoyi.system.service.IHotspotDataRealtimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实时热点数据Controller
 * 
 * @author ruoyi
 * @date 2022-01-20
 */
@RestController
@RequestMapping("/paasplatform/hotspot/realtime")
public class HotspotDataRealtimeController extends BaseController
{
    @Autowired
    private IHotspotDataRealtimeService hotspotDataRealtimeService;

    /**
     * 查询实时热点数据列表
     */
    @PreAuthorize("@ss.hasPermi('paas:realtime:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotspotDataRealtime hotspotDataRealtime)
    {
        startPage();
        List<HotspotDataRealtime> list = hotspotDataRealtimeService.selectHotspotDataRealtimeList(hotspotDataRealtime);
        return getDataTable(list);
    }

    /**
     * 导出实时热点数据列表
     */
    @PreAuthorize("@ss.hasPermi('paas:realtime:export')")
    @Log(title = "实时热点数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotspotDataRealtime hotspotDataRealtime)
    {
        List<HotspotDataRealtime> list = hotspotDataRealtimeService.selectHotspotDataRealtimeList(hotspotDataRealtime);
        ExcelUtil<HotspotDataRealtime> util = new ExcelUtil<HotspotDataRealtime>(HotspotDataRealtime.class);
        util.exportExcel(response, list, "实时热点数据数据");
    }

    /**
     * 获取实时热点数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('paas:realtime:query')")
    @GetMapping(value = "/{hotspotId}")
    public AjaxResult getInfo(@PathVariable("hotspotId") String hotspotId)
    {
        return AjaxResult.success(hotspotDataRealtimeService.selectHotspotDataRealtimeByHotspotId(hotspotId));
    }

    /**
     * 新增实时热点数据
     */
    @PreAuthorize("@ss.hasPermi('paas:realtime:add')")
    @Log(title = "实时热点数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("热点数据添加")
    public AjaxResult add(@RequestBody HotspotDataRealtime hotspotDataRealtime)
    {
        return toAjax(hotspotDataRealtimeService.insertHotspotDataRealtime(hotspotDataRealtime));
    }

    /**
     * 修改实时热点数据
     */
    @PreAuthorize("@ss.hasPermi('paas:realtime:edit')")
    @Log(title = "实时热点数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotspotDataRealtime hotspotDataRealtime)
    {
        return toAjax(hotspotDataRealtimeService.updateHotspotDataRealtime(hotspotDataRealtime));
    }

    /**
     * 删除实时热点数据
     */
    @PreAuthorize("@ss.hasPermi('paas:realtime:remove')")
    @Log(title = "实时热点数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hotspotIds}")
    public AjaxResult remove(@PathVariable String[] hotspotIds)
    {
        return toAjax(hotspotDataRealtimeService.deleteHotspotDataRealtimeByHotspotIds(hotspotIds));
    }
}
